package com.swu.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;

@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "病案查询参数")
public class MedicalRecordQueryDTO extends PageQueryDTO{
    
    @Schema(description = "患者姓名模糊查询")
    private String patientName;
    
    @Schema(description = "病案号精确查询")
    private String medicalRecordId;
    
    @Schema(description = "入院开始时间", example = "2025-01-01")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate admissionBeginTime;
    
    @Schema(description = "入院结束时间", example = "2025-12-31")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate admissionEndTime;
    
    @AssertTrue(message = "入院开始时间不能晚于结束时间")
    public boolean isValidDateRange() {
        if (admissionBeginTime != null && admissionEndTime != null) {
            return !admissionBeginTime.isAfter(admissionEndTime);
        }
        return true;
    }
} 